<template>
  <a-modal
    title="字典项选择"
    :width="1000"
    :visible="visible"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭"
  >
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="12">
          <a-col :md="7" :sm="8">
            <a-form-item label="字典名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入字典名称" v-model="queryParam.dictName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <a-form-item label="字典编号" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入字典编号" v-model="queryParam.dictCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button shape="circle" @click="searchQuery" icon="search"></a-button>
              <a type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a>
            </span>
          </a-col>
        </a-row>
      </a-form>


      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :customRow="onDbClickRow"
        @change="handleTableChange"
      >
      </a-table>
    </div>
  </a-modal>
</template>

<script>
import { filterObj } from '@/utils/util'
import { HjListMixin } from '@/mixins/HjListMixin'
import { getAction } from '@/api/manage'

export default {
  name: 'DictList',
  mixins: [HjListMixin],
  components: {  },
  data() {
    return {
      description: '这是数据字典页面',
      visible: false,
      // 查询条件
      queryParam: {
        dictCode: '',
        dictName: ''
      },
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 120,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '字典名称',
          align: 'left',
          dataIndex: 'dictName'
        },
        {
          title: '字典编号',
          align: 'left',
          dataIndex: 'dictCode'
        },
        {
          title: '描述',
          align: 'left',
          dataIndex: 'description'
        },

      ],
      dict: '',
      labelCol: {
        xs: { span: 8 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 16 },
        sm: { span: 19 }
      },
      url: {
        list: '/sys/dict/list',

      }
    }
  },
  computed: {

  },
  methods: {
    getQueryParams() {
      var param = Object.assign({}, this.queryParam, this.isorter)
      param.field = this.getQueryField()
      param.pageNo = this.ipagination.current
      param.pageSize = this.ipagination.pageSize
      return filterObj(param)
    },
    //取消选择
    handleCancel(e) {
      this.visible = false;
    },

    // 重置字典类型搜索框的内容
    searchReset() {
      var that = this
      that.queryParam.dictName = ''
      that.queryParam.dictCode = ''
      that.loadData(this.ipagination.current)
    },
    show() {
      this.visible=true
    },

    //双击选中事件
    onDbClickRow(record) {
      return {
        on: {
          dblclick: () => {
           //console.log(record)
            this.visible=false
            this.$emit('ok',record.dictCode)
          }
        }
      }
    }



  },
  watch: {
    openKeys(val) {
      console.log('openKeys', val)
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>